package com.haixiaoke.saas.repository.service.impl;

import java.util.Date;
import java.util.List;

import com.haixiaoke.saas.repository.mapper.OpLeadMapper;
import com.haixiaoke.saas.repository.pojo.OpLead;
import com.haixiaoke.saas.repository.service.IOpHouseService;
import com.haixiaoke.saas.repository.service.IOpLeadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 公众号留咨信息Service业务层处理
 *
 * @author qixi
 * @date 2024-01-16
 */
@Service
public class OpLeadServiceImpl implements IOpLeadService {
    @Autowired
    private OpLeadMapper opLeadMapper;
    @Autowired
    private IOpHouseService opHouseService;
    /**
     * 查询公众号留咨信息
     *
     * @param id 公众号留咨信息主键
     * @return 公众号留咨信息
     */
    @Override
    public OpLead selectOpLeadById(Long id) {
        return opLeadMapper.selectOpLeadById(id);
    }

    /**
     * 查询公众号留咨信息列表
     *
     * @param opLead 公众号留咨信息
     * @return 公众号留咨信息
     */
    @Override
    public List<OpLead> selectOpLeadList(OpLead opLead) {
        List<OpLead> opLeads = opLeadMapper.selectOpLeadList(opLead);
        opLeads.forEach(opLead1 -> {
            opLead1.setOpHouse(opHouseService.selectOpHouseById(opLead1.getOpHouseId()));
        });
        return opLeads;
    }

    /**
     * 新增公众号留咨信息
     *
     * @param opLead 公众号留咨信息
     * @return 结果
     */
    @Override
    public int insertOpLead(OpLead opLead) {
        opLead.setCreateTime(new Date());
        return opLeadMapper.insertOpLead(opLead);
    }

    /**
     * 修改公众号留咨信息
     *
     * @param opLead 公众号留咨信息
     * @return 结果
     */
    @Override
    public int updateOpLead(OpLead opLead) {
        opLead.setUpdateTime(new Date());
        return opLeadMapper.updateOpLead(opLead);
    }

    /**
     * 批量删除公众号留咨信息
     *
     * @param ids 需要删除的公众号留咨信息主键
     * @return 结果
     */
    @Override
    public int deleteOpLeadByIds(Long[] ids) {
        return opLeadMapper.deleteOpLeadByIds(ids);
    }

    /**
     * 删除公众号留咨信息信息
     *
     * @param id 公众号留咨信息主键
     * @return 结果
     */
    @Override
    public int deleteOpLeadById(Long id) {
        return opLeadMapper.deleteOpLeadById(id);
    }


}
